#include "CDrawGLScene.h"
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <unistd.h>
#include <cmath>
#include <cstdlib>
#include "CInitGL.h"
#include "CDrawGLScene.h"
#include "Cwindow.h"

using namespace std;

CDrawGLScene::CDrawGLScene()
{

}

void CDrawGLScene::DrawGLScenes()
{

float rtri = 0.0f;
//float depth = -10.0f,Movex = 0.0f, Movey = 0.0f;

  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
  glLoadIdentity();

//  glTranslatef(Movex,Movey,depth);		// Move Left 1.5 Units And Into The Screen 6.0

int FancyRotate();



  glRotatef(rtri,0.0f,1.0f,0.0f);		// Rotate The Pyramid On The Y axis
   //glutWireCube(2.0f);
  glBegin(GL_POLYGON);

  // front
  glColor3f(1.0f,0.0f,0.0f);
  glVertex3f(0.0f, 1.0f, 0.0f);
  glColor3f(0.0f,1.0f,0.0f);
  glVertex3f(-1.0f,-1.0f, 1.0f);
  glColor3f(0.0f,0.0f,1.0f);
  glVertex3f(1.0f,-1.0f, 1.0f);

  // right
  glColor3f(1.0f,0.0f,0.0f);
  glVertex3f( 0.0f, 1.0f, 0.0f);
  glColor3f(0.0f,0.0f,1.0f);
  glVertex3f( 1.0f,-1.0f, 1.0f);
  glColor3f(0.0f,1.0f,0.0f);
  glVertex3f( 1.0f,-1.0f, -1.0f);

  // back
  glColor3f(1.0f,0.0f,0.0f);
  glVertex3f( 0.0f, 1.0f, 0.0f);
  glColor3f(0.0f,1.0f,0.0f);
  glVertex3f( 1.0f,-1.0f, -1.0f);
  glColor3f(0.0f,0.0f,1.0f);
  glVertex3f(-1.0f,-1.0f, -1.0f);

  // left
  glColor3f(1.0f,0.0f,0.0f);
  glVertex3f( 0.0f, 1.0f, 0.0f);
  glColor3f(0.0f,0.0f,1.0f);
  glVertex3f(-1.0f,-1.0f,-1.0f);
  glColor3f(0.0f,1.0f,0.0f);
  glVertex3f(-1.0f,-1.0f, 1.0f);

  glEnd();
    rtri+=0.07f;
  glutSwapBuffers();
}

void CDrawGLScene::ReSizeGLScene(int Width, int Height)
{

  if (Height==0)
    Height=1;

  glViewport(0, 0, Width, Height);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);
  glMatrixMode(GL_MODELVIEW);
}
